/*
 * @Author: jiutian
 * @Date: 2023-02-07 09:01:37
 * @LastEditTime: 2023-02-07 09:54:59
 * @LastEditors:
 */
import { defineStore } from "pinia";
import { ref, reactive, computed } from "vue";
import request from "@api";

export const useStore = defineStore("mian", {
  state: () => {
    return {
      currentUser: JSON.parse(localStorage.getItem("CURRENT_USER")) || {},
    };
  },
  actions: {
    getCurrentUser() {
      request["check/getCurrentUser"]().then((res: any) => {
        if (res.code == 200) {
          this.currentUser = res.data;
          localStorage.setItem("CURRENT_USER", JSON.stringify(res.data));
        }
      });
    },
    loginFunc() {
      this.getCurrentUser();
    },
  },
  getters: {},
});
